import { createApp } from 'vue'
import { setupRouter } from './router'
import { setupElIcons } from './app/element-plus-icons'
import pinia from './store'
import setupDirectives from './directives'
import errorHandler from './plugins/error-handler'
import VueTippy from 'vue-tippy'

import Wrapper from './components/wrapper'
import Modal from './components/modal'
import Icon from './components/icon'

import './assets/styles/index.scss'
import 'virtual:svg-icons-register'

import App from './App.vue'

const app = createApp(App)

async function setupApp() {
  app.config.errorHandler = errorHandler

  app.use(pinia)
  app.use(VueTippy)

  app.component(Wrapper.name, Wrapper)
  app.component(Modal.name, Modal)
  app.component(Icon.name, Icon)

  setupElIcons(app)
  setupDirectives(app)
  await setupRouter(app)
  await app.mount('#app')
}

setupApp()
// update()
